package mearth;
import processing.core.PApplet;
import processing.core.PImage;


public class CellSpatialImage extends PApplet {

	PImage map;
	
	public void setup(){
		size(1280,1024, JAVA2D);
		
		map = loadImage("data/sea002.png");
//		map = loadImage("data/map004.png");
		noSmooth();
		background(0);
//		image(map, 0, 0);
		
		
		map.loadPixels();
		
		GNode root = new GNode(0, 0, map.width, map.height);
		root.partition(map.pixels, map.width);
		
		
		pushMatrix();
		translate(-1280,-1240);
		scale(1f);
		noStroke();
		root.display(this, 1.25f);
		popMatrix();
		stats();
		
//		exit();
	}
	
	public void stats(){
		System.out.println("Nbr nodes parent = " + GNode.nbrParents);
		System.out.println("Nbr nodes leaves = " + GNode.nbrLeaves);
		int memParents = GNode.nbrParents * 32;
		int memLeaves = GNode.nbrLeaves * 16;
		int mem = memParents + memLeaves;
		System.out.println("Memory used:");
		System.out.println("Parents\t" + memParents);
		System.out.println("Leaves\t" + memLeaves);
		System.out.println("Total\t" + mem);
		System.out.println();
	}

	
}
